package com.miao.jni;

public class testByte {


    public static void main(String[] args) {

        //模拟8个像素点
        char[] pixle = {'黑','白','黑','白','黑','白','黑','黑'};
        int data = 0x00;

        for(int i = 0; i<8; i++){
            data = data << 1;
            if(pixle[i] == '黑'){
                data = data | 0x01;
            }
        }
        System.out.println(Integer.toBinaryString(data));

        //取末尾8位转为一个字节
        byte b = (byte)(data & 0xFF);
        System.out.println(b);//-85  ---> 10101011

    }
}
